﻿CREATE PROCEDURE [dbo].[s_Accurint_InstantID_Bulk]
AS
SET IMPLICIT_TRANSACTIONS OFF
DECLARE cur CURSOR READ_ONLY FOR
SELECT TOP 1 b.ID FROM t_Borrower b INNER JOIN t_Loan_Borrower lb ON b.ID = lb.BorrowerID
WHERE InstantIDScore IS NULL AND FirstName > '' AND LastName > ''
ORDER BY ID DESC

DECLARE @BorrID int
OPEN cur

FETCH NEXT FROM cur INTO @BorrID
WHILE @@fetch_status = 0 BEGIN
	PRINT @BorrID
	EXEC s_Accurint_InstantID @BorrID
	IF dbo.Stop() = 1 BREAK
	FETCH NEXT FROM cur INTO @BorrID
END

CLOSE cur
DEALLOCATE cur

